package com.srwl.mytx.fragment;

import android.content.IntentFilter;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;

import com.srwl.mytx.Constant;
import com.srwl.mytx.R;
import com.srwl.mytx.im.IMSClientBootstrap;

public class ConversationListFragment extends BaseConversationListFragment implements View.OnClickListener {
    private static final String TAG = "ConversationList";

    @Override
    protected void initView(View view) {
        super.initView(view);

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Constant.ACTION_PUSH_MESSAGE_REFRESH);

    }


    @Override
    protected void setUpView() {
        super.setUpView();
        //设置登录监听,rest登录完成后， conversationService 才初始化，才能初始化会话列表
        IMSClientBootstrap.getInstance().addLoginListenerList(new IMSClientBootstrap.LoginListener() {
            @Override
            public void onRestLoginSuccess() {
                initConversationListView();

            }
        });
        // registerForContextMenu(conversationListView);

    }


    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        getActivity().getMenuInflater().inflate(R.menu.em_delete_message, menu);
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {

        return true;
    }

    @Override
    public void onClick(View v) {
        getActivity().getSupportFragmentManager().beginTransaction().detach(ConversationListFragment.this).commit();
    }


    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        this.hidden = hidden;

    }

    @Override
    public void onResume() {
        super.onResume();

//        if (!hidden) {
//            updateNoticeUnreadText();
//        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
